<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>角色授权</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    

	<link rel="stylesheet" type="text/css" href="css/maintable.css" ></link>
	<link rel="stylesheet" type="text/css" href="css/edittable.css" ></link>
	
	<script type="text/javascript" src="js/jquery-1.8.0.js"></script> 
	<script type="text/javascript">
		$(function(){
			var menuIdStr = "${menuIdStr}";
			var menuIdArray = menuIdStr.split(",");
			
			//给js的数组扩展一个contains放法
			Array.prototype.contains=function(e){
				for(var i=0;i<this.length;i++){
					if(this[i]==e){
						return true;
					}
				}
				return false;
			}
			
			$("input[type=checkbox]").each(function(){
				if(menuIdArray.contains(this.value)){
					this.checked = true;
				}
			});
		});
		
	</script>
	
  </head>
  
  <body>
  	
  	<div class ="div_title">
		<div class="div_titlename"> 
			<img src="images/san_jiao.gif" ><span>角色授权</span> &nbsp;&nbsp;当前用户角色：${roleInfo.roleName }
		</div>
	</div>
  
  	<form action="RoleServlet.do" method="post">
  		<input type="hidden" name="flag" value="updateRoleMenu">
  		<input type="hidden" name="roleId" value="${roleInfo.id }">
		<table class="main_table">
		    <tr>
		        <th>一级菜单</th>
		        <th>二级菜单</th>
		    </tr>
		    <c:forEach var="m" items="${menuList }">
		    	<tr>
		    		<td>
		    			<input type="checkbox" name="ids" value=${m.id }>${m.menuName }_${m.id} <br>
		    		</td>
		    		<td>
		    			<c:forEach var="m_sub" items="${m.subMenuList }">
		    				<input type="checkbox" name="ids" value=${m_sub.id }>${m_sub.menuName }_${m_sub.id } <br>
		    			</c:forEach>
		    		</td>
		    	</tr>
		    </c:forEach>
		</table>
		<br>&nbsp;&nbsp;
		<input class="form_btn" type="submit" value="保存修改" onclick="return confirm('确定要提交吗')"/>
		<label>${msg }</label>
	</form>
  </body>
</html>
